{% extends "base.html" %}

{% block content %}
<div class="admin-dashboard container">
    <div class="admin-header">
        <h1>编辑夫妻信息</h1>
        <a href="{{ url_for('admin.manage_couples') }}" class="btn">返回列表</a>
    </div>

    <div class="admin-form card">
        <form method="POST" enctype="multipart/form-data">
            {{ form.hidden_tag() }}
            <div class="form-grid">
                <div class="form-group">
                    {{ form.season.label }}
                    {{ form.season(class="form-control") }}
                    {% for error in form.season.errors %}
                    <span class="error">{{ error }}</span>
                    {% endfor %}
                </div>
                <div class="form-group">
                    {{ form.marriage_years.label }}
                    {{ form.marriage_years(class="form-control") }}
                    {% for error in form.marriage_years.errors %}
                    <span class="error">{{ error }}</span>
                    {% endfor %}
                </div>
            </div>

            <div class="couple-section">
                <h3>丈夫信息</h3>
                <div class="form-grid">
                    <div class="form-group">
                        {{ form.husband_name.label }}
                        {{ form.husband_name(class="form-control") }}
                        {% for error in form.husband_name.errors %}
                        <span class="error">{{ error }}</span>
                        {% endfor %}
                    </div>
                    <div class="form-group">
                        {{ form.husband_age.label }}
                        {{ form.husband_age(class="form-control") }}
                        {% for error in form.husband_age.errors %}
                        <span class="error">{{ error }}</span>
                        {% endfor %}
                    </div>
                    <div class="form-group">
                        {{ form.husband_occupation.label }}
                        {{ form.husband_occupation(class="form-control") }}
                        {% for error in form.husband_occupation.errors %}
                        <span class="error">{{ error }}</span>
                        {% endfor %}
                    </div>
                    <div class="form-group">
                        <div class="avatar-preview">
                            <img src="{{ couple.husband_avatar or url_for('static', filename='images/default-avatar.png') }}" 
                                 alt="丈夫头像预览" class="preview-img">
                        </div>
                        {{ form.husband_avatar.label }}
                        {{ form.husband_avatar(class="form-control") }}
                        <small class="form-text text-muted">支持JPG、PNG、GIF格式，大小不超过5MB</small>
                    </div>
                </div>
            </div>

            <div class="couple-section">
                <h3>妻子信息</h3>
                <div class="form-grid">
                    <div class="form-group">
                        {{ form.wife_name.label }}
                        {{ form.wife_name(class="form-control") }}
                        {% for error in form.wife_name.errors %}
                        <span class="error">{{ error }}</span>
                        {% endfor %}
                    </div>
                    <div class="form-group">
                        {{ form.wife_age.label }}
                        {{ form.wife_age(class="form-control") }}
                        {% for error in form.wife_age.errors %}
                        <span class="error">{{ error }}</span>
                        {% endfor %}
                    </div>
                    <div class="form-group">
                        {{ form.wife_occupation.label }}
                        {{ form.wife_occupation(class="form-control") }}
                        {% for error in form.wife_occupation.errors %}
                        <span class="error">{{ error }}</span>
                        {% endfor %}
                    </div>
                    <div class="form-group">
                        <div class="avatar-preview">
                            <img src="{{ couple.wife_avatar or url_for('static', filename='images/default-avatar.png') }}" 
                                 alt="妻子头像预览" class="preview-img">
                        </div>
                        {{ form.wife_avatar.label }}
                        {{ form.wife_avatar(class="form-control") }}
                        <small class="form-text text-muted">支持JPG、PNG、GIF格式，大小不超过5MB</small>
                    </div>
                </div>
            </div>

            <div class="form-group">
                {{ form.story.label }}
                {{ form.story(class="form-control", rows=5) }}
                {% for error in form.story.errors %}
                <span class="error">{{ error }}</span>
                {% endfor %}
            </div>

            <div class="form-actions">
                <button type="submit" class="btn">保存修改</button>
            </div>
        </form>
    </div>
</div>
{% endblock %} 